package com.galaxy.mino;


import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * minio 初始化配置
 * @author anjie
 * @email anjie@032t.com
 * @date 2020年8月10日
 */
@Configuration
public class MyConfigration {

    @Value("${minio.url}")
    private String url;

    @Value("${minio.accessKey}")
    private String accessKey;

    @Value("${minio.secretKey}")
    private String secretKey;

    /**
     * 初始化 minjio 并纳入spring容器
     * @return
     * @throws InvalidPortException
     * @throws InvalidEndpointException
     */
    @Bean
    public MinioClient minioClient() throws InvalidPortException, InvalidEndpointException {

        MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
        System.out.println(
                "             _                                  _       _\n" +
                "  __ _  __ _| | __ ___  ___   _       _ __ ___ (_)_ __ (_) ___\n" +
                " / _` |/ _` | |/ _` \\ \\/ / | | |_____| '_ ` _ \\| | '_ \\| |/ _ \\\n" +
                "| (_| | (_| | | (_| |>  <| |_| |_____| | | | | | | | | | | (_) |\n" +
                " \\__, |\\__,_|_|\\__,_/_/\\_\\\\__, |     |_| |_| |_|_|_| |_|_|\\___/\n" +
                " |___/                    |___/\n" +
                "                                                    银河漫游科技有限公司"
        );

        return minioClient;
    }
}
